package com.approval.approvalapp.center.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.center.bean.ThingsCensusItemBean;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class ThingsCensusItemAdapter extends BaseRecycleListAdapter<ThingsCensusItemBean> {


    public ThingsCensusItemAdapter(List<ThingsCensusItemBean> mList, Context context) {
        super(mList, context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.things_item_layout;
    }

    @Override
    public int getItemCount() {
        return 5;
    }

    @Override
    public RecyclerView.ViewHolder createHolder(View view) {
        return new ViewHolder(view);
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, ThingsCensusItemBean bean, int position) {
        if(holder instanceof  ViewHolder){
//            ((ViewHolder) holder).setData(bean,position);
        }
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if(holder instanceof  ViewHolder){
            ((ViewHolder) holder).setData(position);
        }
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        @Bind(R.id.view1)
        View view1;
        @Bind(R.id.tv_title1)
        TextView tvTitle1;
        @Bind(R.id.view2)
        View view2;
        @Bind(R.id.tv_title2)
        TextView tvTitle2;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void setData(int position){

            switch (position) {
                case 0:
                    setViewColor("行政许可","行政检查","#4071FF","#7D8198","#F8AF35","#7D8198");
                    break;
                case 1:
                    setViewColor("行政处罚", "行政征收", "#3BD5FF","#7D8198","#FFD649","#7D8198");
                    break;
                case 2:
                    setViewColor("行政确认", "行政奖励", "#EC376F","#7D8198","#8942FF","#7D8198");
                    break;
                case 3:
                    setViewColor("行政强制", "公共服务", "#C11F2E","#7D8198","#5840FF","#7D8198");
                    break;
                case 4:
                    setViewColor("行政给付", "行政裁决", "#DE463A","#7D8198","#5793F3","#7D8198");
                    break;

            }

        }

        public void setViewColor(String str1, String str2, String viewC1, String viewC2, String viewC3, String viewC4){
            view1.setBackgroundColor(Color.parseColor(viewC1));
            tvTitle1.setTextColor(Color.parseColor(viewC2));
            tvTitle1.setText(str1);
            tvTitle2.setText(str2);
            view2.setBackgroundColor(Color.parseColor(viewC3));
            tvTitle2.setTextColor(Color.parseColor(viewC4));
        }

    }
}
